package com.ttg.web.controller.common;

import com.ttg.common.entities.BaseResult;
import com.ttg.common.utils.RequestParamsManager;
import com.ttg.model.dto.*;
import com.ttg.web.service.IndustryInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description： 行业分类
 * Author: chenyou
 * Date: 2025/11/6 15:46
 * Company: ttg
 * Copyright: Copyright (c) 2025
 */
@Slf4j
@Api("行业分类管理")
@RestController
@RequestMapping("/industry")
public class IndustryInfoController {

    @Autowired
    private IndustryInfoService industryInfoService;

    @ApiOperation("一级行业")
    @RequestMapping("/firstLevelList")
    public BaseResult firstLevelList(){
        return BaseResult.success(industryInfoService.firstLevelList());
    }


    @ApiOperation("二级行业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "clsId1",value = "一级行业分类",required = true,dataType = "string",paramType = "form")
    })
    @RequestMapping("/twoLevelList")
    public BaseResult twoLevelList(@RequestBody(required = false) String data){
        IndustrySelectDTO industrySelectDTO = RequestParamsManager.transformRequestParam(data, IndustrySelectDTO.class);
        return BaseResult.success(industryInfoService.twoLevelList(industrySelectDTO));
    }

    @ApiOperation("分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword1",value = "一级分类关键字（一级分类ID/一级分类名称）",required = true,dataType = "string",paramType = "form"),
            @ApiImplicitParam(name = "keyword2",value = "二级分类关键字（二级分类ID/二级分类名称）",required = true,dataType = "string",paramType = "form"),
            @ApiImplicitParam(name = "keyword3",value = "三级分类关键字（二级分类ID/二级分类名称）",required = true,dataType = "string",paramType = "form")
    })
    @RequestMapping("/page")
    public BaseResult page(@RequestBody(required = false) String data){
        IndustryPageDTO reqDto = RequestParamsManager.transformRequestParam(data, IndustryPageDTO.class);
        return BaseResult.success(industryInfoService.page(reqDto));
    }
}
